<%@ Page Title="Member_Info List" Language="C#" AutoEventWireup="true" CodeBehind="Member_InfoList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Member_InfoList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
    $(function () {
        $('.form_date').datetimepicker({
            language: "zh_CN",
            format: "yyyy-mm-dd",
            autoclose: true,
            todayBtn: true,
            todayHighlight: true,
            pickerPosition: "bottom-left",
            startView: 2,
            minView: 2,
            forceParse: 0
        });
    });
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Member_Info, "Member_Info", "Member_Info") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <form class="form-horizontal">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %></label>
                                <div class="col-md-9">
                                    <input type="email" id="MemberAccount" maxlength="100" name="MemberAccount" class="form-control" placeholder="<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.M_Common, "MobileNo", "手机号") %></label>
                                <div class="col-md-9">
                                    <input type="email" id="MobileNo" maxlength="100" name="MobileNo" class="form-control" placeholder="<%: R(LanguageModule.M_Common, "MobileNo", "手机号") %>">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.M_Common, "Status", "状态") %></label>
                                <div class="col-md-9">
                                    <select name="Status" id="Status" class="form-control">
                                        <option value=""><%: R(LanguageModule.M_Common, "All", "全部") %></option>
                                        <option value="0"><%=R(LanguageModule.M_Common, "NotActivated", "未激活") %></option>
                                        <option value="1"><%=R(LanguageModule.M_Common, "normal", "正常") %></option>
                                        <option value="2"><%=R(LanguageModule.M_Common, "nolog", "不能登录") %></option>
                                        <option value="3"><%=R(LanguageModule.M_Common, "Inoperablefunds", "不能操作资金") %></option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Info, "CreateTime", "创建时间") %></label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" data-date-format="yyyy/mm/dd" id="StartDate" class="form-control form_date" />
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" data-date-format="yyyy/mm/dd" id="EndDate" class="form-control form_date" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <button type="button" id="btnQuery" name="btnQuery" class="btn btn-default btn-ar btn-primary">
                                <i class="fa fa-search "></i>
                                <%: R(LanguageModule.M_Common, "Query") %>
                            </button>
                        </div>
                    </div>
                </form>
                <div class="form-group"></div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnNormal"><i class="fa fa-check "></i>
                            正常</a>
                        <a href="#" class="btn btn-info" id="btnCannotLogin"><i class="fa fa-ban "></i>
                            不能登录</a>
                        <a href="#" class="btn btn-info" id="btnNotMoney"><i class="fa fa-warning "></i>
                            不能操作资金</a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;
    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Member/Handlers/Member_InfoHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    d.MemberAccount = $('#MemberAccount').val();
                    d.MobileNo = $('#MobileNo').val();
                    d.Status = $('#Status').val();
                    d.StartDate = $('#StartDate').val();
                    d.EndDate = $('#EndDate').val();
                }
            },
            "columns": [
                    { "data": 'RowIndex', "title": "#" },
                    //{
                    //    data: "MemberAccount",
                    //    title: '操作',
                    //    width: 60,
                    //    render: function (data, type, row) {
                    //        return "<a href='javascript:;' class='btn btn-info btn-sm' title='编辑' onclick='Edit(\"" + row.MemberAccount + "\")'><i class='fa fa-edit'> 编辑</i></a>";
                    //    },
                    //    className: "dt-body-center"
                    //},
                    { "data": 'MemberAccount', "title": "<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>" },
                    { "data": 'LastName', "title": "<%: R(LanguageModule.Member_Info, "LastName", "姓名") %>" },
                    <%--{ "data": 'FirstName', "title": "<%: R(LanguageModule.Member_Info, "FirstName", "名") %>" },--%>
                    { "data": 'Status', "title": "<%: R(LanguageModule.M_Common, "Status", "状态") %>", render: mStatus },
<%--                    { "data": 'ErrorTimes', "title": "<%: R(LanguageModule.Member_Info, "ErrorTimes", "错误次数") %>", render: fnumber },
                    { "data": 'ErrorDateTime', "title": "<%: R(LanguageModule.Member_Info, "ErrorDateTime", "错误时间") %>" },--%>
                    { "data": 'Sex', "title": "<%: R(LanguageModule.Member_Info, "Sex", "性别") %>", render: fSex },
                    { "data": 'CredentialsType', "title": "<%: R(LanguageModule.Member_Info, "CredentialsType", "证件类型") %>" },
                    { "data": 'CredentialsNum', "title": "<%: R(LanguageModule.Member_Info, "CredentialsNum", "证件号") %>" },
                    { "data": 'Email', "title": "<%: R(LanguageModule.Member_Info, "Email", "邮箱") %>" },
                    { "data": 'MobileNo', "title": "<%: R(LanguageModule.Member_Info, "MobileNo", "手机号") %>" },
                    { "data": 'AreaName', "title": "<%: R(LanguageModule.Member_Info, "AreaName", "所属区域") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Member_Info, "CreateTime", "创建时间") %>" },	
                  <%--  { "data": 'ModifyTime', "title": "<%: R(LanguageModule.Member_Info, "ModifyTime", "修改时间") %>" },--%>
            ]
        });
        $('#btnQuery').click(function () {
            if (validateStartDateEndDate($('#StartDate').val(), $('#EndDate').val())) {
                dt.ajax.reload();
            }
        });
    });

    //0未激活，1正常，2不能登录，3不能操作资金
    function mStatus(value, row) {
        switch (value) {
            case 0:
                return "<span class='label label-default'><%=R(LanguageModule.M_Common, "NotActivated", "未激活") %> </span>";
                break;
            case 1:
                return "<span class='label label-primary'><%=R(LanguageModule.M_Common, "normal", "正常") %></span>";
                break;
            case 2:
                return "<span class='label label-success'><%=R(LanguageModule.M_Common, "nolog", "不能登录") %></span>";
                break;
            case 3:
                return "<span class='label label-danger'><%=R(LanguageModule.M_Common, "Inoperablefunds", "不能操作资金") %></span>";
                break;
        }
    }

    //编辑
    //function Edit(MemberAccount) {
    //    if (MemberAccount.length > 0) {
    //        loadPage("Member/Member_InfoItem.aspx?MemberAccount=" + MemberAccount);
    //    }
    //}

    $('#btnEdit').click(function () {
        if ($('#table tbody tr.selected').length > 0) {
            loadPage("Member/Member_InfoItem.aspx?MemberAccount=" + dt.row('.selected').data().MemberAccount);
        }
        else {
            $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
            $(".alert").show();
        }
    });

    //正常
    $('#btnNormal').click(function () {
        if ($('#table tbody tr.selected').length > 0) {
            $('#confirm .btn-primary').unbind('click');
            jconfirm("你确定要修改些状态吗？", function () {
                modifyStatus(dt.row('.selected').data().MemberAccount,1);
            })
        }
        else {
            $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
            $(".alert").show();
        }
    });

    //不能登录
    $('#btnCannotLogin').click(function () {
        if ($('#table tbody tr.selected').length > 0) {
            $('#confirm .btn-primary').unbind('click');
            jconfirm("你确定要修改些状态吗？", function () {
                modifyStatus(dt.row('.selected').data().MemberAccount, 2);
            })
        }
        else {
            $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
            $(".alert").show();
        }
    });

    //不能操作资金
    $('#btnNotMoney').click(function () {
        if ($('#table tbody tr.selected').length > 0) {
            $('#confirm .btn-primary').unbind('click');
            jconfirm("你确定要修改些状态吗？", function () {
                modifyStatus(dt.row('.selected').data().MemberAccount, 3);
            })
        }
        else {
            $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
            $(".alert").show();
        }
    });

    function modifyStatus(MemberAccount,Status) {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "Member/Handlers/Member_InfoHandler.ashx?type=modifyStatus",
            data: { MemberAccount: MemberAccount, Status: Status },
                success: function (data) {
                    if (data.isSuccess) {
                        dt.ajax.reload();
                    }
                    else {
                        $(".alert > .content").html(data.message);
                        $(".alert").show();
                    }
                },
                error: function (message) {
                    $(".alert > .content").html("系统异常，请稍后再试");
                    $(".alert").show();
                }
            });
        }

</script>
